#include <libavutil/log.h>
#include <libavformat/avio.h>

int main(int argc, char *argv[])
{
    char *dir = "./";
    int ret = 0;
    AVIODirContext *av_dir_context = NULL;
    AVIODirEntry *av_dir_entry = NULL;
    av_log_set_level(AV_LOG_INFO);
    ret = avio_open_dir(&av_dir_context, dir, NULL);
    if (ret < 0)
    {
        av_log(NULL, AV_LOG_ERROR, "can't open dir: %s\n", av_err2str(ret));
        goto __ERROR;
    }
    while (1)
    {
        ret = avio_read_dir(av_dir_context, &av_dir_entry);
        if (ret < 0)
        {
            av_log(NULL, AV_LOG_ERROR, "can't read dir: %s\n", av_err2str(ret));
            goto __ERROR;
        }
        if(!av_dir_entry){
            break;
        }
        av_log(NULL, AV_LOG_INFO, "%-12"PRId64"%s\n", av_dir_entry->size, av_dir_entry->name);
        avio_free_directory_entry(&av_dir_entry);
    }

__ERROR:
    if (av_dir_context != NULL)
    {
        avio_close_dir(&av_dir_context);
    }
    return 0;
}
